#include "widget.h"
#include "ui_widget.h"
#include<fstream>
#include<QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //将数据从文件中读取
    std::ifstream file("D:/code/qt/combobox_2/idol.txt");
    if(!file.is_open())qDebug()<<"!file.is_open()";
    std::string line;
    while (std::getline(file, line))
    {
        ui->comboBox->addItem(QString::fromStdString(line));
    }
    file.close();

}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    QString figure=ui->comboBox->currentText();
    if(figure=="真神")ui->label_2->setText("真的是你呀！");
    else if (figure=="沙漠骆驼")ui->label_2->setText("Siuuuuuuuuuu!!!");
    else if (figure=="芙蓉王")ui->label_2->setText("做个wink");
    else if (figure=="曼巴")ui->label_2->setText("see u again");
    else ui->label_2->setText("五行之外");
}

